//
//  WelcomeController.m
//  PetExchange
//
//  Created by zhibao on 2021/3/10.
//

#import "WelcomeController.h"
#import "FirstPayController.h"
#import "HomeController.h"
@interface WelcomeController ()
@property(nonatomic,strong)UIScrollView *scrollView;
@end

@implementation WelcomeController

- (void)viewDidLoad {
    [super viewDidLoad];
    _scrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, MY_Screen_W, MY_Screen_H)];
    _scrollView.pagingEnabled = YES;
    _scrollView.backgroundColor = [UIColor blackColor];
    _scrollView.showsHorizontalScrollIndicator = NO;
    _scrollView.bounces = NO;
    [self.view addSubview:_scrollView];
    
    for (int i = 0; i< 3; i ++) {
        UIView *bgView = [[UIView alloc]initWithFrame:CGRectMake(MY_Screen_W * i, 0, MY_Screen_W, MY_Screen_H)];
        bgView.backgroundColor = [UIColor whiteColor];
        [_scrollView addSubview:bgView];
        
        NSString *tempName = [NSString stringWithFormat:@"ch_%d.jpg",i + 1];
        NSString *imgName = LocalizedString(tempName);
        if(LL_iPhoneX){
            tempName = [NSString stringWithFormat:@"ch_%d_x.jpg",i + 1];
            imgName = LocalizedString(tempName);
        }
        UIImageView *imgView1 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:imgName]];
        [bgView addSubview:imgView1];
        
        [imgView1 mas_makeConstraints:^(MASConstraintMaker *make) {
            //make.center.equalTo(bgView);
            make.left.top.bottom.right.equalTo(bgView);
            
        }];
        
        if (i == 2) {
            UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
            btn.backgroundColor = MYBlue;
            [bgView addSubview:btn];
            btn.layer.cornerRadius = 23;
            [btn mas_makeConstraints:^(MASConstraintMaker *make) {
                make.bottom.mas_equalTo(-60);
                make.right.equalTo(bgView).offset(-20);
                make.height.mas_equalTo(46);
                make.width.mas_equalTo(90);
            }];
            btn.titleLabel.font = MY_SCALE_SemiboldFONT(16);
            [btn setTitle:LocalizedString(@"继续") forState:UIControlStateNormal];
            [btn setTitleColor:UIColor.whiteColor forState:UIControlStateNormal];
            [btn addTarget:self action:@selector(gotoController) forControlEvents:UIControlEventTouchUpInside];
        }
    }
    _scrollView.contentSize = CGSizeMake(MY_Screen_W * 3, MY_Screen_H);
}

-(void)gotoController{
    [[NSUserDefaults standardUserDefaults] setValue:WelcomeFlag forKey:WelcomeFlag];
    FirstPayController *controller = [[FirstPayController alloc] init];
    LNavigationViewController *nav = [LNavigationViewController rootVC:controller];
    nav.gk_openScrollLeftPush = YES;
    nav.gk_openSystemNavHandle = YES;
    MYAPP.window.rootViewController = nav;
}

@end
